package com.example.guide.scheduling;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

@Component
@Order(2)
public class CustomApplicationRunner implements ApplicationRunner {

    @Autowired
    TaskService taskService;

    @Override
    public void run(ApplicationArguments args) throws InterruptedException, ExecutionException {
        System.out.println("CustomApplicationRunner");
        System.out.println(Thread.currentThread().getId());
        taskService.excutVoidTask();
        Future<String> s =  taskService.excuteValueTask();
        System.out.println(s.get());
    }
}
